package com.example.config;

import com.example.constants.Constants;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQDLXConfig {
    //交换机名称
    private String dlxDirectExchangeName = Constants.MY_DLX_DIRECT_EXCHANGE;

    //队列名称
    private String dlxQueueName = Constants.MY_DLX_QUEUE_NAME;

    @Bean
    public DirectExchange dlxDirectExchangeName() {
        DirectExchange directExchange = new DirectExchange(dlxDirectExchangeName);
        return directExchange;
    }

    @Bean
    public Queue dlxQueueName() {
        Queue queue = new Queue(dlxQueueName);
        return queue;
    }

    @Bean
    public Binding binding6(Queue dlxQueueName,DirectExchange dlxDirectExchangeName) {
        //将队列绑定到交换机
        Binding binding = BindingBuilder.bind(dlxQueueName).to(dlxDirectExchangeName).with("dlx");
        return binding;
    }
}